package com.enqualcomm.kids.mvp.register;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.enqualcomm.kids.view.BasePager;

import java.util.List;


/**
 * Created by yinzhiqun on 2015/10/14.
 *
 */
public class RegisterPagerAdapter extends PagerAdapter {
    private List<BasePager> pages;
    public RegisterPagerAdapter(List<BasePager> pages){
        this.pages = pages;
    }

    @Override
    public int getCount() {
        return pages.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(pages.get(position).getRootView());
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View rootView = pages.get(position).getRootView();
        container.addView(rootView);
        return rootView;
    }
}
